package com.bqy.myokgo.base.okgo;

import com.bqy.myokgo.base.okgo.callback.DialogCallback;
import com.bqy.myokgo.base.okgo.callback.HttpManagerCallback;
import com.bqy.myokgo.base.okgo.callback.StringCallback;
import com.bqy.myokgo.base.okgo.callback.isDialogCallback;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams;

import java.util.Map;

/**
 * 熊猫先生
 * 2018/10/23:10:06
 * Http请求二次包装 方便更换
 */

public class OKHttp {

    public static <T> void post(Map map, String URL, StringCallback<T> Callback) {
        HttpParams params = new HttpParams();
        for (Object key : map.keySet()) {
            params.put(key.toString(), map.get(key).toString());
        }

        OkGo.<T>post(URL)
                .tag(URL)
                .params(params)
                .execute(Callback);
    }

    public static <T> void post(Map map, String URL, DialogCallback<T> Callback) {
        HttpParams params = new HttpParams();
        for (Object key : map.keySet()) {
            params.put(key.toString(), map.get(key).toString());
        }

        OkGo.<T>post(URL)
                .tag(URL)
                .params(params)
                .execute(Callback);
    }

    public static <T> void post(Map map, String URL, isDialogCallback<T> Callback) {
        HttpParams params = new HttpParams();
        for (Object key : map.keySet()) {
            params.put(key.toString(), map.get(key).toString());
        }

        OkGo.<T>post(URL)
                .tag(URL)
                .params(params)
                .execute(Callback);
    }

    public static <T> void post(Map map, String URL, HttpManagerCallback<T> Callback) {
        HttpParams params = new HttpParams();
        for (Object key : map.keySet()) {
            params.put(key.toString(), map.get(key).toString());
        }

        OkGo.<T>post(URL)
                .tag(URL)
                .params(params)
                .execute(Callback);
    }
}